/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.unl.asd.tablas;

import edu.unl.asd.modelo.Error;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *

 */
public class ErrorModeloTabla extends AbstractTableModel {

    String titulos[] = {"Ref.", "Error", "Tipo de Error"};
    List<Error> errors;
    Error error;

    public ErrorModeloTabla(List<Error> errors) {
        this.errors = errors;
    }

    public ErrorModeloTabla() {
        errors = new ArrayList<Error>();
    }

    @Override
    public int getRowCount() {
        return errors != null ? errors.size() : 0;
    }

    @Override
    public int getColumnCount() {
        return titulos.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        error = errors.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return this.errors.indexOf(error) + 1;
            case 1:
                return error.getNombreError();
            case 2:
                return error.getTipoError();
        }
        return null;
    }

    @Override
    public String getColumnName(int colum) {
        return titulos[colum];
    }

    public Error getError() {
        return error;
    }

    public void setError(Error error) {
        this.error = error;
    }

    public List<Error> getErrors() {
        return errors;
    }

    public void setErrors(List<Error> errors) {
        this.errors = errors;
    }
}
